package tt.love.hw.common;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

public class ResourceBundleContext {
	
	Map<Locale, ResourceBundle> resourceBundleContext = new HashMap<Locale, ResourceBundle>();
	private Locale defaultLocale = new Locale("","");
	
	public ResourceBundle getResourceBundle(Locale locale){
		ResourceBundle resourceBundle = resourceBundleContext.get(locale);
		if(resourceBundle==null){
			resourceBundle = ResourceBundle.getBundle("messages",defaultLocale);
		}
		return resourceBundle;
	}

	public ResourceBundleContext() {
		Locale zhLocale = new Locale("zh","CN");
		resourceBundleContext.put(zhLocale, ResourceBundle.getBundle("messages",zhLocale));
	}
	
	

}
